﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data;
using Microsoft.SharePoint;
using System.Web;
using JM.JCY.Common;

namespace JM.JCY.SharePointComponent.Document.PublicDocument
{
    public partial class PublicDocumentUserControl : UserControl
    {
        string listName = JCYConstant.SharePointListName.PublicDocumentLibrary;
        protected void Page_Load(object sender, EventArgs e)
        {

            SPWeb web = SPContext.Current.Web;
            SPList docList = web.Lists[listName];
            this.lvDocument.ListId = docList.ID.ToString();
            lvDocument.ViewId = docList.Views["HomeView"].ID.ToString();
            string onclick = string.Format("javascript:NewItem2(event, '{0}');javascript:return false;", docList.DefaultNewFormUrl);
            this.idHomePageNewItem.Attributes.Add("onclick", onclick);

            if (CommonFunction.IsApplicationAdmin(11))
                this.idHomePageNewItem.Visible = true;
            else
                this.idHomePageNewItem.Visible = false;


        }

        protected void lbViewAllDoc_Click(object sender, EventArgs e)
        {

            Response.Redirect(SPContext.Current.Site.ServerRelativeUrl + "PublicDocPages/ViewAllDocuments.aspx");
        }
    }
}
